import request from "@/utils/request";

// 获取员工列表
export function getEmployeeList(params) {
  return request({
    url: "/sys/user",
    params,
  });
}

// 导出Excel
export function exportExcel() {
  return request({
    url: "/sys/user/export",
    responseType: "blob",
  });
}

// 下载导入Excel模板
export function downloadImportExcelTemplate() {
  return request({
    url: "/sys/user/import/template",
    responseType: "blob",
  });
}

// 上传Excel文件
export function uploadExcel(data) {
  return request({
    url: "/sys/user/import",
    method: "POST",
    data,
  });
}

// 删除员工
export function delEmployee(id) {
  return request({
    url: `/sys/user/${id}`,
    method: "DELETE",
  });
}

// 新增员工
export function addEmployee(data) {
  return request({
    url: `/sys/user`,
    method: "post",
    data,
  });
}
// 修改员工
export function updataEmployee(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: "put",
    data,
  });
}

// 获取员工数据
export function getEmployeeDetail(id) {
  return request({
    url: `/sys/user/${id}`,
  });
}

// 获取查询角色列表
export function getRoleList(params) {
  return request({
    url: `/sys/role`,
    params
  });
}
// 给员工分配角色
export function assignRole(data) {
  return request({
    url: `/sys/user/assignRoles`,
    method: 'PUT',
    data
  });
}
